<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>物资管理列表</title>
    <jsp:include page="/WEB-INF/view/commons/css.jsp" />
</head>
<body >
<div id="main-container" class="container-fluid">
    <form action="reportStock/dolist" method="post" name="searchForm" id="searchForm" role="form" class="form-horizontal">
            <div class="form-group">
                    <label class="col-sm-1 control-label">物资名称：</label>
                    <div class="col-md-4">
                                <input type="text" id="materialsName" class="form-control" name="materialsName" value="${entity.materialsName}" placeholder="物资名称">
                    </div>
                    <label class="col-sm-1 control-label">物资类别：</label>
                    <div class="col-md-4">
                		<d:select id="materialsType" name="materialsType" clazz="selectpicker" list="${materialsTypes}" selected="${entity.materialsType}" />     
                    </div>
            </div>
           	
			<div class="row">
        		<div class="col-md-10">
            		<p>	
            			<a id="export_menu_btn" onclick = "exportexcal()" class="btn btn-sm btn-pink"><i class="fa fa-file-excel-o icon-share"></i> 导出</a>
						<button id="searchBtn" type="button" class="btn btn-sm btn-info"><i class="fa fa-search"></i> 查询</button>
			    	</p>
        		</div>
    		</div>	
    </form>
    
    <form id= "exportexcalform" method=post action="${ctx}reportStock/export" target="_blank" >
		<input type="hidden" name="materialsName"  />
		<input type="hidden" name="materialsType"  />
		<input type="hidden" name="beginAddTime"  />
		<input type="hidden" name="endAddTime"  />
	</form>

    <table id="table_data" class="table table-striped table-bordered table-hover">
        <thead>
        <tr>
            <th width="10%">物资编号</th>
            <th width="10%">物资名称</th>
            <th width="10%">物资类别</th>
            <th width="10%">规格</th>
            <th width="10%">单位</th>
            <th width="10%">库存数量</th>
        </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</div>
<!-- 返回顶部  -->
<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
</a>
<!-- script start -->
<jsp:include page="/WEB-INF/view/commons/js.jsp" />
<script type="text/javascript">
    $(document).ready(function(e) {
        var table = $("#table_data").dataTable({
            ajax: function(data, callback, settings){
                tableAjax($("#searchForm"),data, callback, settings);
            },
            //列表表头字段
            columns: [
                { "data": "materialsCode",name:"materials_code",orderable:false },
                { "data": "materialsName",name:"materials_name",orderable:false },
                { "data": "materialsTypeStr",name:"materials_type", orderable:false },
                { "data": "specification",name:"specification",orderable:false },
                { "data": "unitStr",name:"unit",orderable:false },
                { "data": "stockNum",name:"stock_num",orderable:false },
        ]
    }).api();

        //查询条件
        $("#searchForm").submit(function(){
            table.ajax.reload();
            return false;
        });
    });
    
    //点击导出 将页面数据加载到表单中
	function exportexcal(){
		/* if($.trim($("#materialsName").val())=='' && $.trim($("#materialsType").val())=='' && $.trim($("#beginAddTime").val())=='' && $.trim($("#endAddTime").val())=='' ){
			layer.msg("没有任何筛选条件，系统无法筛选结果，导出动作被取消！");
			return false;
		}  */
		$('#exportexcalform input[name="materialsName"]').val($.trim($("#materialsName").val()));
		$('#exportexcalform input[name="materialsType"]').val($.trim($("#materialsType").val()));
		$('#exportexcalform input[name="beginAddTime"]').val($.trim($("#beginAddTime").val()));
		$('#exportexcalform input[name="endAddTime"]').val($.trim($("#endAddTime").val()));
		$('#exportexcalform').submit();
	}
	
</script>
<!-- script end -->
</body>
</html>